GrossWithdrawal
This assignment accepts allocation instructions with methods of percent, amount, units and prorata. Methods for all allocations can be the same or mixed. The total removed from the funds must match the sum of the MoneyTypes and the sum of the cash values removed from the fund's deposits must match the expected fund removal amounts. MoneyType values must be negative.
- Set the assignment’s “MoneyType value” to the sum total of the MoneyType values.
- Order the funds in the allocation.
- For each fund in the allocation,
- If the allocation method is percent,
- Calculate the fund’s “removal amount” as the assignment’s “MoneyType value” X allocation percent. Round the result to the currency definition.
- The last fund is adjusted so that the sum total of fund “removal amounts” is equal to the assignment’s “MoneyType value”.
- If the “removal amount” is greater than the fund’s cash value, report an error.
- If the allocation method is units,
- Calculate fund's "temporary amount" as the allocation units X the fund's unit value for the activity effective date. Round the result to the currency definition.
- If the allocation method is amount,
- The fund's "removal amount" is the allocation amount.
- If the allocation method is percent,
- For each fund with the allocation method of units or percent of fund,
- Calculate the fund's "removal amount" as the assignment's "MoneyType value" X the fund's "temporary amount" / sum total of "temporary amounts". Round the result to the currency definition.
- The last fund is adjusted so that the sum total of fund "removal amounts" is equal to the assignment's "MoneyType value".
- If the "removal amount is greater than the fund's cash value, report an error.
- If no error,
- For each fund in reverse order,
- If the fund’s “removal amount” is greater than the fund’s value, accumulate the difference and make fund’s “removal amount” equal to the fund’s value. This is the “accumulated difference”.
- If the fund’s value is greater than its “removal amount”, add as much of the “accumulated difference” to the fund’s “removal amount” as the fund’s value will allow and adjust the “accumulated difference” by what the fund’s value allowed.
- At the end of the loop, error if the “accumulated difference” is greater than 0.
- For each non-zero value MoneyType in the order configured,
- For each fund in the original order,
- If the last non-zero value MoneyType,
- Calculate the amount to remove from the fund as the difference of the fund’s “removal amount” and the fund’s “distributed amount”.
- Otherwise,
- Calculate the fund’s “removal amount” per MoneyType and round to the currency definition: allocation percent X the MoneyType’s value.
- The last fund is adjusted so the sum of the “removal amount” values equals the MoneyType’s value.
- Accumulate the “removal amount”. This is the “distributed amount".
- If the last non-zero value MoneyType,
- If tracking by fund, the “removal amount” becomes a FundValuationEffect record.
- An ending FundValue record is affected by the “removal amount".
- "Remaining removal amount” is set to the fund’s “removal amount”.
If tracking by deposit, For each of the fund’s deposits in LIFO or FIFO order,
- Calculate “deposit removal” as the lesser of the deposit’s value and fund’s “remaining removal amount”.
- Decrement the “remaining removal amount” by the “deposit removal".
- If the “remaining removal amount” is 0, looping through the deposits is complete.
- For each fund in the original order,
- For each fund in reverse order,
-
If tracking funds by deposit,
-
For each removal amount from a deposit,
-
A new DepositValuationEffect record persists the amount of change in a fund’s value and maintains tracking by seed deposit, money type code, bucket (where applicable) and deposit date in the fund.
-
If the fund is variable and the cash value of the remaining units is less than the smallest denomination of the currency, remove all units.
-
-
-
An ending DepositValue record is created to reflect the ending balances of the deposit’s CashValue, RawCashValue and Units.
-
An ending record will exist for every beginning DepositValue record.
-
The difference between beginning and ending record values is the change persisted in the DepositValuationEffect record for the same fund, seed deposit, money type code and deposit date.
-
-
An ending FundValue record is created to reflect the ending balances of the fund's CashValue, RawCashValue and Units.
-
If rounding level is deposit, CashValue is the sum of rounded cash value from the fund's ending DepositValue records.
-
If rounding level is fund, CashValue is the sum of unrounded cash value from the fund's ending DepositValue records. The result is rounded to currency definition.
-
Units and RawCashValue are the sum of the units and raw cash values, respectively, from the fund's ending DepositValue records.
-
-
- If not tracking funds by deposit,
- A FundValuationEffect record persists the amount of change in a fund’s value.
- If the fund is variable and the cash value of the remaining units is less than the smallest denomination of the currency, remove all units.
- An ending FundValue record is created to reflect the fund's ending balances.
- An ending record will exist for every beginning FundValue record.
- The difference between beginning and ending record values is the fund's changes persisted in the FundValuationEffect record.
- A FundValuationEffect record persists the amount of change in a fund’s value.